package org.panda.tcmoc.persistence.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import org.apache.log4j.Logger;
import org.panda.tcmoc.domain.FxInfo;
import org.panda.tcmoc.persistence.dao.FxInfoDao;
import org.panda.tcmoc.persistence.db.DbHelper;
import org.panda.tcmoc.persistence.db.impl.DbHelperImpl;

public class FxInfoDaoImpl implements FxInfoDao {
	private DbHelper _dbHelper = new DbHelperImpl();
	private Logger logger = Logger.getLogger(SpProductDaoImpl.class);

	public int deleteList(List<FxInfo> arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	public List<FxInfo> getFxInfosByDealTicketNo(String arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public int insertList(List<FxInfo> list) {
		int result = 0;
		for (FxInfo fxInfo : list) {
			Connection conn = _dbHelper.getConn();
			String insertSql = "INSERT INTO FX values(?,?,?,?)";
			try {
				PreparedStatement ps = conn.prepareStatement(insertSql);
				ps.setString(1, fxInfo.getDealTicketNo());
				ps.setString(2, fxInfo.getDesc());
				ps.setDate(3, new java.sql.Date(fxInfo.getDate().getTime()));
				ps.setDouble(4, fxInfo.getValue());
				result = ps.executeUpdate();
			} catch (SQLException e) {
				e.printStackTrace();
				return result;
			}

		}
		return result;
	}

	public int updateList(List<FxInfo> arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

}
